package com.stenio.fancat.common.constants;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * @author liuan
 * @create 2019-01-18 19:26
 */
public class Test {

    public static void main(String[] args) {
        SimpleDateFormat date = new SimpleDateFormat("yyyyMMdd");
        //date.format();
        boolean result = isNow(new Date());
        System.out.println( result?"是今天。":"不是今天。" );
    }

    private static boolean isNow(Date date) {
        //当前时间
        Date now = new Date();
        SimpleDateFormat sf = new SimpleDateFormat("yyyyMMdd");
        //获取今天的日期
        String nowDay = sf.format(now);
        //对比的时间
        String day = sf.format(date);
        return day.equals(nowDay);
    }

}
